.text
.section .rodata
.LC0:
	.string	"varr[1] = %d\n"
	
.text
.globl	main
.type	main, @function
main:
    pushq %rbp
    movq %rsp, %rbp

    // 把rbx保存栈上
    pushq %rbx

    subq $40, %rsp

    movq %rsp, %rax
    movq %rax, %rbx

    // sz = 10
    movl $10, -44(%rbp)

    movl -44(%rbp), %eax
    movslq %eax, %rdx
    // %rdx = 10 - 1 = 9
    subq $1, %rdx
    // 把9存入-40到-32的内存栈上
    movq %rdx, -40(%rbp)

    // rdx又变成10
    movslq %eax, %rdx
    // 把10赋值给r8
    movq %rdx, %r8
    movl $0, %r9d
    movslq %eax, %rdx
    // 把10赋值给rsi
    movq %rdx, %rsi
    movl $0, %edi
    cltq

    // %rdx = 40
    leaq 0(, %rax, 4), %rdx
    movl $16, %eax
    subq $1, %rax
    // %rax = 40 + F
    addq %rdx, %rax

    movl $16, %edi
    // 把rdx清空，以便执行div
    movl $0, %edx
    divq %rdi

    // rax存储需要动态分配栈的长度，又赋值给rcx
    imulq $16, %rax, %rax
    movq %rax, %rcx

    // 保持12位对其
    andq $-4096, %rcx

    movq %rsp, %rdx
    subq %rcx, %rdx
.L2:
    cmpq %rdx, %rsp
    je .L3
    subq $4096, %rsp
    // 没看懂这里是在干什么
    orq $0, 4088(%rsp)
    jmp .L2
    // 以上就是为了计算出动态数组需要分配的栈空间

.L3:
    movq %rax, %rdx
    andl $4095, %edx
    subq %rdx, %rsp
    movq %rax, %rdx
    andl $4095, %edx
    testq %rdx, %rdx
    je .L4
    andl $4095, %eax
    subq $8, %rax
    addq %rsp, %rax
    orq $0, (%rax)
.L4:
    movq %rsp, %rax
    addq $3, %rax
    shrq $2, %rax
    salq $2, %rax
    movq %rax, -32(%rbp)
    movl $0, -48(%rbp) /* i */
    jmp .L5
.L6:
    movl -48(%rbp) /* i */, %eax
    leal 1(%rax), %ecx
    movq -32(%rbp) /* varr */, %rax
    movl -48(%rbp) /* i */, %edx
    movslq %edx, %rdx
    movl %ecx, (%rax, %rdx, 4)
    addl $1, -48(%rbp) /* i */

.L5:
    movl -48(%rbp) /* i */, %eax
    cmpl -44(%rbp) /* sz */, %eax
    jl .L6

    movq -32(%rbp) /* varr */, %rax
    movl 4(%rax), %esi
    leaq .LC0(%rip), %rdi
    movl $0, %eax
    call printf

    movl $0, %eax
    movq -8(%rbp), %rbx
    movq %rbp, %rsp
    popq %rbp
    ret